/****************************************************************************
**
** Copyright (C) 2013 Ernesto Barragan <ernestus at gmail dot com>
**
** GNU General Public License Usage
** This file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
****************************************************************************/

#include "fontchooser.h"
#include "ui_fontchooser.h"

FontChooser::FontChooser(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::FontChooser)
{
    ui->setupUi(this);
}

FontChooser::~FontChooser()
{
    delete ui;
}

QFont FontChooser::currentFont() const
{
    QFont font = ui->fontComboBox->currentFont() ;
    font.setBold( ui->boldCheckBox->isChecked() ) ;
    font.setPointSize( ui->sizeSpinBox->value() ) ;
    return font ;
}

void FontChooser::setCurrentFont(const QFont &font)
{
    ui->fontComboBox->setCurrentFont( font );
    ui->boldCheckBox->setChecked( font.bold() );
    ui->sizeSpinBox->setValue( font.pointSize() );
}

void FontChooser::on_onlyMonospacedCheckBox_clicked( bool checked )
{
    if( checked )
    {
        ui->fontComboBox->setFontFilters( QFontComboBox::MonospacedFonts ) ;
    }
    else
    {
        ui->fontComboBox->setFontFilters( QFontComboBox::AllFonts ) ;
    }
}
